new Vue({
   el:'#app',
    data:{
        case_law: {
            caseId: '',
            clientId: {
                clientName:''
            }
        },
        tableData: [],
        dialogVisible: false, // 查看的模态框显示
        law:{			//模态框显示的案件详情信息
            caseId:'',
            clientId:{
                cname:'',
            },
            oppositeId:{
                cname:'',
            },
            locusStandi:'',
            causeOfAction:'',
            causeDetails:'',
            caseStatus:'',
            objectOfAction:'',
            caseTypeid:{
                typeName:''
            },
            recordFilename:'',
            submitId:{
                user_name:''
            },
            submitDate:'',
            mainLawyer:{
                empName:''
            },
            agencyMoney:'',
            blendMoney:'',
            amountMoney:'',
            courtId:{
                courtName:''
            },
            sessionDate:'',
            stateSessionDate:'',
            trialDate:'',
            closeState:'',
            closeMode:'',
            closeDate:'',
            closeDate:''
        },
        updatevisible:false,  //用来打开修改的模态框
        courtOne:{     //显示单条案件时间  
            caseId:'', 
            clientId:{
                clientName:''
            },
            sessionDate:'',
            stateSessionDate:'',
            trialDate:''
        }
    },
    created(){
      this.init(); 
    },
    methods:{
        init(){
           this.$http.post("http://localhost:8080/case_count/queryCourtByLaw"
               ,{emulateJSON:true}).then(result=>{
               var msg = eval("("+result.body+")");
               this.tableData = msg.data; 
           });
        }, 
        handleClose(done) {
            this.$confirm('确认关闭？')
                .then(_ => {
                    done();
                })
                .catch(_ => {});
        },
        queryByid(caseid){ //跳转到这个案件的详细信息页面
            //打开模态框
            this.dialogVisible = true;
            //得到选择的案件id
            this.$http.post("http://localhost:8080/law/queryByid",
                {"caseid":caseid},
                {emulateJSON:true}).then(result=>{
                var msg = eval("("+result.body+")");
                this.law = msg.data;
            });
        },
        initupdate_court(caseid){  //打开案件模态框赋值基本信息
            this.updatevisible = true;
            
            var msg = this.tableData;
            for(var i = 0; i<msg.length; i++){
                if (caseid == msg[i].caseId){
                    this.courtOne.caseId = msg[i].caseId;
                    this.courtOne.clientId.clientName = msg[i].clientId.clientName;
                    this.courtOne.sessionDate = msg[i].sessionDate;
                    this.courtOne.stateSessionDate = msg[i].stateSessionDate;
                    this.courtOne.trialDate = msg[i].trialDate;
                } 
            }
        },
        update_court(){     //修改案件信息
            var data = JSON.stringify(this.courtOne);
            this.$http.post("http://localhost:8080/case_count/update_courtTime",
                {"data":data},{emulateJSON:true}).then(result=>{
                var msg = eval("("+result.body+")");
                    if(msg.code == 0){
                        alert("修改成功");
                        this.init();
                    }
            });
        },
        LikeQuery(){  //模糊查询
            var data = JSON.stringify(this.case_law);
            this.$http.post("http://localhost:8080/case_count/queryCourtByLaw",
                {"data":data},{emulateJSON:true}).then(result=>{
                var msg = eval("("+result.body+")");
                this.tableData = msg.data;
            });
        }
    }
});